<#include "common/layout/__mainlayout.html">
<#assign navLink='console:userlocation:list' />
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;margin:0;}
#l-map{height:100%;width:78%;float:left;border-right:2px solid #bcbcbc;}
#r-result{height:100%;width:20%;float:left;}
</style>
<@mainlayout>
<div class="row-content am-cf">
	<div class="row">
		<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
			<div class="widget am-cf">
				<div class="widget-head am-cf">
					<div class="widget-title am-fl">用户分布图</div>
					<div id="allmap" style="width:100%;height: 100%"></div>
				<div class="widget-body  widget-body-lg am-fr">
				</div>
			</div>
		</div>
	</div>
</div>
</@mainlayout>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=20113cae0e19e18482601f9ebe80c678"></script>
<script type="text/javascript" src="${realpath}/resources/bmap/TextIconOverlay_min.js"></script>
<script type="text/javascript" src="${realpath}/resources/bmap/MarkerClusterer_min.js"></script>
<script>
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(105, 32),6);
map.enableScrollWheelZoom();
var MAX = 10;
var markers = [];
var pt = null;
var i = 0;



$(document).ready(function() {
	$.ajax({
	url: '${realpath}/console/userlocation/load',
	type: 'post',
	dataType: 'json',
	success:function(result){
		run(result.data);
	}
});

	function run(data){
		for (i=0; i < data.length; i++) {
		            var item = data[i];
		            pt = new BMap.Point(item.lng, item.lat);
		            markers.push(new BMap.Marker(pt));
		        }
		        //最简单的用法，生成一个marker数组，然后调用markerClusterer类即可。
		        var markerClusterer = new BMapLib.MarkerClusterer(map, {markers:markers});
		        map.addOverlay(markerClusterer);
		}
});


map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.OverviewMapControl());              //添加默认缩略地图控件
map.addControl(new BMap.OverviewMapControl({isOpen:true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT}));   //右上角，打开

</script>

